<?php
class DBManager {
	private static $instance;
	
	public static function getInstance() {
		if(DBManager::$instance==null) {
			$instance = new DBManager();
		}
		
		return $instance;
	}
	
	private function DBManager() {
		
	}
	
	function query($sql) {
		$cid = mysql_connect('localhost', 'root', 'root')or die("DB Connection error!");
		$result = mysql_db_query("qeshi_bokdb", $sql, $cid);
		$ret = array();
		while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
			$ret[] = $row;
		}
		
		mysql_close($cid);
		return $ret;
	}
	
	function insertUpdate($sql) {
		$cid=mysql_connect('localhost', 'root', 'root')or die("DB Connection error!");
		mysql_select_db("qeshi_bokdb", $cid);
		mysql_query($sql);
		mysql_close($cid);
	}
	
	public static function escape($in, $comma=true) {
		$out= "'".str_replace("'", "''", $in)."'";
		if($comma)
			return $out.", ";
		else
			return $out;
	}

}
?>
